function [ vol,dvol] = volume(V,T,phi)

ne = size(T,1);
vol = zeros(ne,1);
dvol = vol;

for i = 1:ne
    vtx = V(T(i,:),:); 
    dvol(i) = 0.5*(abs(det([1 1 1; vtx([1 2 4],:)'])) + ...
        abs(det([1 1 1; vtx([2 3 4],:)'])) );
    vol(i) = dvol(i)*phi(i);
end

% for j = 1:nely
%     for i = 1:nelx
%         vol((j-1)*nelx+i) = dvol((j-1)*nelx+i)*phi((j-1)*nelx+i);
%     end
% end